//
//  参考：
//  https://www.w3cschool.cn/groovy/groovy_file_io.html
//  https://www.cnblogs.com/xudong-bupt/p/3758136.html
//
//
class TestProp {

    public static void main(String[] args) {

        def filename = "src\\file\\one.properties"
        def props = new Properties();
        props.load(new FileInputStream(filename));

        println("===================遍历一=========================")

        Enumeration enumeration = props.keys();
        while (enumeration.hasMoreElements()) {
            def key = enumeration.nextElement();
            def val = props.get(key);
            println "property : " + key + "  =  " + val;
        }

        println("===================遍历二=========================")

        Iterator<String> it = props.stringPropertyNames().iterator();
        while (it.hasNext()) {
            String key = it.next();
            println(key + ":" + props.getProperty(key));
        }

        println("===================获取方式一=========================")

        def name = props["name"]
        def id = props["id"]
        def age = props["age"]
        println("name = $name , id = $id ， age = $age")

        println("===================获取方式二=========================")
        def name2 = props.get("name")
        def id2 = props.get("id")
        def age2 = props.get("age")
        println("name2 = $name2 , id2 = $id2 ， age2 = $age2")

        println("===================获取方式三=========================")
        def name3 = props.getProperty("name")
        def id3 = props.getProperty("id")
        def age3 = props.getProperty("age")
        println("name3 = $name3 , id3 = $id3 ， age3 = $age3")
    }


}
